let jwt = require("jsonwebtoken");
let pathList = ["/login"];
const auto = () => {
    return (ctx,next) => { 
       const path = ctx.path;
       const token = ctx.headers.authorization
       if(pathList.includes(path)){
           next()
       }else{
        if(token){
            try{
                const tokens = jwt.verify(token,"1906A");
                next();
            }catch(err){
                ctx.body = {
                    code:403,
                    msg:"token失败"
                }
            }
        }else{
            ctx.body = {
                code:404,
                msg:"没有token"
            }
        }
       }
    }
}
module.exports = auto